<?php
	require "conn.php";
	header("Content-type: text/html; charset=utf-8");
	
	//注册
	if(isset($_POST['str']) || isset($_POST['all'])){
		$phone=@$_POST['str'];  //@容错
	}else{
		exit('非法操作');
	}
	
	$res=mysql_query("select * from user where phone='$phone'");
	if(mysql_fetch_array($res)){  //有值代表用户名存在
		echo true;  //有重复
	}else{
		echo false;  //无重复
	}
	
	if(isset($_POST['all'])){
		$phone=$_POST['phone'];
		$pass=md5($_POST['pass']);
		$query="insert user(phone,password) values('$phone','$pass')";
		mysql_query($query);
	}
	
?>